package com.ruoyi.common.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;

import com.ruoyi.common.entity.UserWechat;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

/**
 * 用户微信绑定信息 Mapper 接口
 */
@Mapper
public interface UserWechatMapper extends BaseMapper<UserWechat> {

    /**
     * 根据 openid 查询绑定记录
     */
    @Select("SELECT * FROM user_wechat WHERE openid = #{openid}")
    UserWechat selectByOpenid(@Param("openid") String openid);

    /**
     * 根据 unionid 查询绑定记录（可用于多应用统一用户）
     */
    @Select("SELECT * FROM user_wechat WHERE unionid = #{unionid}")
    UserWechat selectByUnionid(@Param("unionid") String unionid);
    @Select("SELECT * FROM user_wechat WHERE user_id = #{userId}")
    UserWechat selectByUserId(Long userId);
}